﻿<%--
///////////////////////////////////////////////////////////////////////////
/// File: <FileName>
/// Description: 
///    -  本文件是由代码生成工具自动生成的，如非必要，不要修改，若有新增内容，新建一个partial类进行新增。
///    -  此文件是根据facade模式和接口隔离原则创建的。各个子业务之间的关联在这里建立。
///    <Description>
/// Copyright© <DateTime.Now.Year> <Copyright>
/// History:
///     <DateTime.Now>    My.GenCode    Original Version
///////////////////////////////////////////////////////////////////////////
--%>
<%@ Page Language="C#" Inherits="<<NameSpace>>.Web.BasePage" AutoEventWireup="true" %>
<%@import namespace="System" %>
<%@import namespace="System.Collections.Generic" %>

<%@import namespace="<<NameSpace>>.Domain.Entities" %>
<%@import namespace="<<NameSpace>>.Web.Controllers" %>

<script runat="server">
   
    #region Page事件
    //
    protected void Page_Init(object sender,EventArgs e)
    {
    }
    //
    protected void Page_Error(object sender,EventArgs e)
    {
        Exception objErr = Server.GetLastError().GetBaseException();
        string err =  "<b>Error Caught in Page_Error event</b><hr><br>" +
            "<br><b>Error in: </b>" + Request.Url.ToString() +
            "<br><b>Error Message: </b>" + objErr.Message.ToString()+
            "<br><b>Stack Trace:</b><br>" +
                            objErr.StackTrace.ToString();
        Response.Write(err.ToString());
        //Server.ClearError();
    }
    //
    protected void Page_Load(object sender, EventArgs e)
    {
        string op = Request.QueryString["Op"];
        bool b = <<CallHandlerMethods>>;
        if( !b )
            Response.Write( AjaxHelper.ResponseError("没有找到请求的命令") );
    }
    #endregion
    
    #region Handler Methods
    [loop<<HandlerMethods>>]
    /// <summary>
    /// <<HandlerClassName>>
    /// </summary>
    protected bool <<HandlerClassName>>Caller( string op )
    {
        <<HandlerClassName>> _this = new <<HandlerClassName>>(this);
        
        string response = "";
        switch( op )
        {
            case "<<CreateMethodName>>":
                response = AjaxHelper.Response(new AjaxHelper.Command<object>(_this.<<CreateMethodName>>));
                break;
                
            case "<<UpdateMethodName>>":
                response = AjaxHelper.Response(new AjaxHelper.Command<int>(_this.<<UpdateMethodName>>));
                break;
                
            case "<<DeleteMethodName>>":
                response = AjaxHelper.Response(new AjaxHelper.Command<int>(_this.<<DeleteMethodName>>));
                break;
                
            case "<<ReadDetailMethodName>>":
                response = AjaxHelper.Response(new AjaxHelper.Command<<<EntityClassName>>>(_this.<<ReadDetailMethodName>>));
                break;
                
            case "<<ReadListMethodName>>":
                response = AjaxHelper.Response(new AjaxHelper.ListCommand<IList<<<EntityClassName>>>>(_this.<<ReadListMethodName>>));
                break;    
 
            default:
                return false;
        }
        
        Response.Write( response );
        return true;
    }
    [/loop<<HandlerMethods>>]
    #endregion
    
</script>
